package com.cheboohui.iqs.spider.pingan.price.get;

import java.util.ArrayList;
import java.util.List;

import com.cheboohui.iqs.spider.pingan.entity.C01Duty;
import com.cheboohui.iqs.spring.entity.Insurance;

/**
 * 车险处理
 * 
 * @author xielonghai
 *
 */
public class InsuranceDeal {

	/**
	 * 险别处理
	 * 
	 * @param i
	 * @param vehicleLossInsuredValue
	 * @return
	 */
	public static ArrayList<C01Duty> getInsurance(List<Insurance> insuranceList, String actualPrice,int seat) {
		/** 商业险列表 */
		ArrayList<C01Duty> c01DutyList = new ArrayList<C01Duty>();
		for (Insurance i : insuranceList) {
			C01Duty ins = getIns(i, actualPrice, seat-1);
			if (null != ins)
				c01DutyList.add(ins);
		}

		return c01DutyList;
	}

	private static C01Duty getIns(Insurance i, String actualPrice,int seat) {
		switch (i.getCode()) {
		case "BL":
			return DutyCreater.CreateDuty01(actualPrice);
		case "BLD":
			return DutyCreater.CreateDuty27();
		case "BT":
			return DutyCreater.CreateDuty03(actualPrice);
		case "BTD":
			return DutyCreater.CreateDuty48();
		case "BTR":
			return DutyCreater.CreateDuty02(String.valueOf(doubleToInt(i.getAmount())));
		case "BTRD":
			return DutyCreater.CreateDuty28();
		case "BD":
			return DutyCreater.CreateDuty04(dToI(i.getAmount()));
		case "BDD":
			return DutyCreater.CreateDuty49();
		case "BP":
			return DutyCreater.CreateDuty05(dToI(i.getAmount()),seat);
		case "BPD":
			return DutyCreater.CreateDuty80();
		case "BN":
			return DutyCreater.CreateDuty17(dToI(i.getAmount()));
		case "BND":
			return DutyCreater.CreateDuty75();
		case "BG":
			return DutyCreater.CreateDuty08(i.getType());
		case "BR":
			return DutyCreater.CreateDuty57(i.getType(), i.getPate());
		case "BNP":
			return DutyCreater.CreateDuty18(actualPrice);
		case "BNPD":
			return DutyCreater.CreateDuty77(actualPrice);
		case "BW":
			return DutyCreater.CreateDuty41();
		case "BWD":
			return DutyCreater.CreateDuty79();
		default:
			return null;
		}
	}

	/**
	 * double /10000 to int
	 * 
	 * @param price
	 * @return
	 */
	private static int doubleToInt(double price) {
		int p = (int) price;
		p = p / 10000;
		return p;
	}

	/**
	 * double to int
	 * 
	 * @param price
	 * @return
	 */
	private static String dToI(double price) {
		int p = (int) price;
		return String.valueOf(p);
	}

}
